<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let nameArr = ['赵云', '黄忠', '关羽', '张飞', '马超', '刘备', '曹操']
        len = nameArr.length
        for(let i = 0; i < len; i++) {
            // 随机索引
            let index = Math.floor(Math.random() * nameArr.length)
            console.log(nameArr[index]);
            nameArr.splice(index, 1)
            nameArr.pop()
        }
    </script>
</body>
</html>